<?php

namespace App\Http\Controllers\admin;

use App\Dao\CursorsDao;
use App\Services\Code;

class CursorController extends BaseController
{
    public function cursors()
    {
        if(getIsHasPage()){
            return Code::message('',200,CursorsDao::cursors(request()->all()));
        }
        return view('admin.cursors.cursors');
    }

    public function add()
    {
        if(isPost()){
            $params = request()->all();
            CursorsDao::add($params);
            return Code::message('',200);
        }
        return view('admin.cursors.add');
    }

    public function edit()
    {
        if(isPost()){
            $params = request()->all();
            CursorsDao::edit($params);
            return  Code::message();
        }
        $info = CursorsDao::cursors_info(['cursors_id'=>request('cursors_id')]);
        return view('admin.cursors.edit',[
            'info'=>$info
        ]);
    }

    public function delete()
    {
        $params = request()->all();
        CursorsDao::delete($params);
        return Code::message('删除成功',200);
    }
}
